/* tslint:disable */
// generated by typescript-json-validator
import {inspect} from 'util';
import Ajv from 'ajv';
import TauriConfig from './config';
export const ajv = new Ajv({"allErrors":true,"coerceTypes":false,"format":"fast","nullable":true,"unicode":true,"uniqueItems":true,"useDefaults":true});

ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json'));

export {TauriConfig};
export const TauriConfigSchema = {
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false,
  "defaultProperties": [
  ],
  "definitions": {
    "CliArg": {
      "additionalProperties": false,
      "defaultProperties": [
      ],
      "description": "A CLI argument definition",
      "properties": {
        "conflictsWith": {
          "description": "sets a conflicting argument by name\ni.e. when using this argument, the following argument can't be present and vice versa",
          "type": "string"
        },
        "conflictsWithAll": {
          "description": "the same as conflictsWith but allows specifying multiple two-way conflicts per argument",
          "type": "string"
        },
        "description": {
          "description": "the argument description which will be shown on the help information\ntypically, this is a short (one line) description of the arg",
          "type": "string"
        },
        "index": {
          "description": "The positional argument index, starting at 1.\n\nThe index refers to position according to other positional argument.\nIt does not define position in the argument list as a whole. When utilized with multiple=true,\nonly the last positional argument may be defined as multiple (i.e. the one with the highest index).",
          "type": "number"
        },
        "longDescription": {
          "description": "the argument long description which will be shown on the help information\ntypically this a more detailed (multi-line) message that describes the argument",
          "type": "string"
        },
        "maxValues": {
          "description": "specifies the maximum number of values are for this argument.\nfor example, if you had a -f <file> argument where you wanted up to 3 'files' you would set .max_values(3), and this argument would be satisfied if the user provided, 1, 2, or 3 values.",
          "type": "number"
        },
        "minValues": {
          "description": "specifies the minimum number of values for this argument.\nfor example, if you had a -f <file> argument where you wanted at least 2 'files' you would set `minValues: 2`, and this argument would be satisfied if the user provided, 2 or more values.",
          "type": "number"
        },
        "multiple": {
          "description": "specifies that the argument may appear more than once.\nfor flags, this results in the number of occurrences of the flag being recorded. For example -ddd or -d -d -d would count as three occurrences.\nfor options there is a distinct difference in multiple occurrences vs multiple values. For example, --opt val1 val2 is one occurrence, but two values. Whereas --opt val1 --opt val2 is two occurrences.",
          "type": "boolean"
        },
        "multipleOccurrences": {
          "description": "specifies that the argument may appear more than once.",
          "type": "boolean"
        },
        "name": {
          "description": "the unique argument name",
          "type": "string"
        },
        "possibleValues": {
          "description": "specifies a list of possible values for this argument. At runtime, the CLI verifies that only one of the specified values was used, or fails with an error message.",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "requireEquals": {
          "description": "requires that options use the --option=val syntax\ni.e. an equals between the option and associated value",
          "type": "boolean"
        },
        "required": {
          "description": "sets whether or not the argument is required by default\nrequired by default means it is required, when no other conflicting rules have been evaluated\nconflicting rules take precedence over being required.",
          "type": "boolean"
        },
        "requiredIf": {
          "additionalItems": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "string"
              }
            ]
          },
          "description": "allows specifying that an argument is required conditionally with the signature [arg: string, value: string]\nthe requirement will only become valid if the `arg`'s value equals `${value}`.",
          "items": [
            {
              "type": "string"
            },
            {
              "type": "string"
            }
          ],
          "minItems": 2,
          "type": "array"
        },
        "requiredUnless": {
          "description": "sets an arg that override this arg's required setting\ni.e. this arg will be required unless this other argument is present",
          "type": "string"
        },
        "requiredUnlessAll": {
          "description": "sets args that override this arg's required setting\ni.e. this arg will be required unless all these other arguments are present",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "requiredUnlessOne": {
          "description": "sets args that override this arg's required setting\ni.e. this arg will be required unless at least one of these other arguments are present",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "requires": {
          "description": "sets an argument by name that is required when this one is present\ni.e. when using this argument, the following argument must be present",
          "type": "string"
        },
        "requiresAll": {
          "description": "sets multiple arguments by names that are required when this one is present\ni.e. when using this argument, the following arguments must be present",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "requiresIf": {
          "additionalItems": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "string"
              }
            ]
          },
          "description": "allows a conditional requirement with the signature [arg: string, value: string]\nthe requirement will only become valid if `arg`'s value equals `${value}`",
          "items": [
            {
              "type": "string"
            },
            {
              "type": "string"
            }
          ],
          "minItems": 2,
          "type": "array"
        },
        "short": {
          "description": "the short version of the argument, without the preceding -\nNOTE: Any leading - characters will be stripped, and only the first non - character will be used as the short version",
          "type": "string"
        },
        "takesValue": {
          "description": "specifies that the argument takes a value at run time.\nNOTE: values for arguments may be specified in any of the following methods\n- Using a space such as -o value or --option value\n- Using an equals and no space such as -o=value or --option=value\n- Use a short and no space such as -ovalue",
          "type": "boolean"
        }
      },
      "required": [
        "name"
      ],
      "type": "object"
    },
    "CliConfig": {
      "additionalProperties": false,
      "defaultProperties": [
      ],
      "description": "describes a CLI configuration",
      "properties": {
        "afterHelp": {
          "description": "adds additional help information to be displayed in addition to auto-generated help\nthis information is displayed after the auto-generated help information\nthis is often used to describe how to use the arguments, or caveats to be noted.",
          "type": "string"
        },
        "args": {
          "description": "list of args for the command",
          "items": {
            "$ref": "#/definitions/CliArg"
          },
          "type": "array"
        },
        "beforeHelp": {
          "description": "adds additional help information to be displayed in addition to auto-generated help\nthis information is displayed before the auto-generated help information.\nthis is often used for header information",
          "type": "string"
        },
        "description": {
          "description": "command description which will be shown on the help information",
          "type": "string"
        },
        "longDescription": {
          "description": "command long description which will be shown on the help information",
          "type": "string"
        },
        "subcommands": {
          "additionalProperties": {
            "$ref": "#/definitions/CliConfig"
          },
          "defaultProperties": [
          ],
          "description": "list of subcommands of this command\n\nsubcommands are effectively sub-apps, because they can contain their own arguments, subcommands, usage, etc.\nthey also function just like the app command, in that they get their own auto generated help and usage",
          "type": "object"
        }
      },
      "type": "object"
    }
  },
  "description": "Tauri configuration",
  "properties": {
    "build": {
      "additionalProperties": false,
      "defaultProperties": [
      ],
      "description": "build/dev configuration",
      "properties": {
        "beforeBuildCommand": {
          "description": "a shell command to run before `tauri build` kicks in",
          "type": "string"
        },
        "beforeDevCommand": {
          "description": "a shell command to run before `tauri dev` kicks in",
          "type": "string"
        },
        "devPath": {
          "description": "the app's dev server URL, or the path to the directory containing an index.html to open",
          "type": "string"
        },
        "distDir": {
          "description": "the path to the app's dist dir\nthis path must contain your index.html file",
          "type": "string"
        },
        "withGlobalTauri": {
          "type": "boolean"
        }
      },
      "required": [
        "devPath",
        "distDir"
      ],
      "type": "object"
    },
    "ctx": {
      "additionalProperties": false,
      "defaultProperties": [
      ],
      "description": "the context of the current `tauri dev` or `tauri build`",
      "properties": {
        "debug": {
          "description": "whether the app should be built on debug mode or not",
          "type": "boolean"
        },
        "dev": {
          "description": "whether we're running on the dev environment or not",
          "type": "boolean"
        },
        "exitOnPanic": {
          "description": "defines we should exit the `tauri dev` process if a Rust code error is found",
          "type": "boolean"
        },
        "prod": {
          "description": "whether we're building for production or not",
          "type": "boolean"
        },
        "target": {
          "description": "the target of the compilation (see `rustup target list`)",
          "type": "string"
        }
      },
      "type": "object"
    },
    "tauri": {
      "additionalProperties": false,
      "defaultProperties": [
      ],
      "description": "tauri root configuration object",
      "properties": {
        "bundle": {
          "additionalProperties": false,
          "defaultProperties": [
          ],
          "description": "tauri bundler configuration",
          "properties": {
            "active": {
              "description": "whether we should build your app with tauri-bundler or plain `cargo build`",
              "type": "boolean"
            },
            "category": {
              "type": "string"
            },
            "copyright": {
              "type": "string"
            },
            "deb": {
              "additionalProperties": false,
              "defaultProperties": [
              ],
              "properties": {
                "depends": {
                  "items": {
                    "type": "string"
                  },
                  "type": "array"
                },
                "useBootstrapper": {
                  "type": "boolean"
                }
              },
              "type": "object"
            },
            "exceptionDomain": {
              "type": "string"
            },
            "externalBin": {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "icon": {
              "description": "the app's icons",
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "identifier": {
              "description": "the app's identifier",
              "type": "string"
            },
            "longDescription": {
              "type": "string"
            },
            "osx": {
              "additionalProperties": false,
              "defaultProperties": [
              ],
              "properties": {
                "frameworks": {
                  "items": {
                    "type": "string"
                  },
                  "type": "array"
                },
                "license": {
                  "type": "string"
                },
                "minimumSystemVersion": {
                  "type": "string"
                },
                "useBootstrapper": {
                  "type": "boolean"
                }
              },
              "type": "object"
            },
            "resources": {
              "description": "app resources to bundle\neach resource is a path to a file or directory\nglob patterns are supported",
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "shortDescription": {
              "type": "string"
            },
            "targets": {
              "anyOf": [
                {
                  "items": {
                    "type": "string"
                  },
                  "type": "array"
                },
                {
                  "type": "string"
                }
              ],
              "description": "the bundle targets, currently supports [\"deb\", \"osx\", \"msi\", \"appimage\", \"dmg\"] or \"all\""
            }
          },
          "required": [
            "icon",
            "identifier"
          ],
          "type": "object"
        },
        "cli": {
          "$ref": "#/definitions/CliConfig",
          "description": "app's CLI definition"
        },
        "edge": {
          "additionalProperties": false,
          "defaultProperties": [
          ],
          "properties": {
            "active": {
              "type": "boolean"
            }
          },
          "type": "object"
        },
        "embeddedServer": {
          "additionalProperties": false,
          "defaultProperties": [
          ],
          "description": "the embedded server configuration",
          "properties": {
            "active": {
              "description": "whether we should use the embedded-server or the no-server mode",
              "type": "boolean"
            },
            "port": {
              "anyOf": [
                {
                  "enum": [
                    "random"
                  ],
                  "type": "string"
                },
                {
                  "type": "number"
                }
              ],
              "description": "the embedded server port number or the 'random' string to generate one at runtime"
            }
          },
          "type": "object"
        },
        "inliner": {
          "additionalProperties": false,
          "defaultProperties": [
          ],
          "properties": {
            "active": {
              "type": "boolean"
            }
          },
          "type": "object"
        },
        "security": {
          "additionalProperties": false,
          "defaultProperties": [
          ],
          "properties": {
            "csp": {
              "type": "string"
            }
          },
          "type": "object"
        },
        "whitelist": {
          "additionalProperties": {
            "type": "boolean"
          },
          "defaultProperties": [
          ],
          "properties": {
            "all": {
              "type": "boolean"
            }
          },
          "required": [
            "all"
          ],
          "type": "object"
        },
        "window": {
          "additionalProperties": false,
          "defaultProperties": [
          ],
          "properties": {
            "fullscreen": {
              "type": "boolean"
            },
            "height": {
              "type": "number"
            },
            "resizable": {
              "type": "boolean"
            },
            "title": {
              "type": "string"
            },
            "width": {
              "type": "number"
            }
          },
          "required": [
            "title"
          ],
          "type": "object"
        }
      },
      "required": [
        "bundle",
        "edge",
        "embeddedServer",
        "inliner",
        "security",
        "whitelist",
        "window"
      ],
      "type": "object"
    }
  },
  "required": [
    "build",
    "ctx",
    "tauri"
  ],
  "type": "object"
};
export type ValidateFunction<T> = ((data: unknown) => data is T) & Pick<Ajv.ValidateFunction, 'errors'>
export const isTauriConfig = ajv.compile(TauriConfigSchema) as ValidateFunction<TauriConfig>;
export default function validate(value: unknown): TauriConfig {
  if (isTauriConfig(value)) {
    return value;
  } else {
    throw new Error(
      ajv.errorsText(isTauriConfig.errors!.filter((e: any) => e.keyword !== 'if'), {dataVar: 'TauriConfig'}) +
      '\n\n' +
      inspect(value),
    );
  }
}
